home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
public
/
RTF
/
elements.h
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-01
|
3KB
|
130 lines
/* $Header: /usr/people/pcd/Src/RTF/RCS/elements.h,v 1.1 92/11/23 12:58:51 pcd Exp Locker: pcd $
*/
#ifndef __elements_h
#define __elements_h
#include "space.h"
#include "textflow.h"
class View;
class ParagraphFormat{
public:
ParagraphFormat();
enum {max_tabs = 10};
enum {quad_left, quad_center, quad_right, quad_full} justification;
Inches left_indent;
Inches right_indent;
Inches first_indent;
Inches space_before;
Inches space_after;
Inches space_between;
void normal();
void add_tab_stop(Inches ts)
{ if(tabqty < max_tabs)
stops[tabqty++] = ts;
};
int tabs() const
{ return tabqty; }
void newtabs()
{ tabqty=0; }
static void default_tab_width(Inches w)
{ default_tab_width_ = w; };
// This must be set before any calls to tab() are made.
Inches tab(int n) const
// tab(3) returns 2" if there are only 3 tab stops
{ return n < tabqty ? stops[n] : (double)(n+1) * default_tab_width_; };
private:
Inches stops[max_tabs];
int tabqty;
static Inches default_tab_width_;
};
class CharacterFormat{
public:
CharacterFormat()
{ plain(); };
void plain()
{ bold = italic = underline = font_family = super = sub = 0;
foreground = 0;
#ifdef FONT_SIZES
size = 24;
#endif
};
#ifdef FONT_SIZES
char size;
#endif
char bold, italic, underline;
char font_family, super, sub;
int foreground;
unsigned long fg_pixel;
};
/***** formatting elements ******/
class NewLineFlow : public TextFlow{
public:
NewLineFlow(TextFlow& parent, TextPosition first, TextPosition last)
: TextFlow(parent, first, last) {};
Qty character_shape(TextPosition, Qty, Extent, Extent&, int) const;
virtual Coord font_ascent() const
{ return 1; }; // must be > 0
virtual Coord space_after() const
{ return 0; };
};
class ParagraphFlow : public TextFlow{
public:
ParagraphFlow(TextFlow& p, TextPosition f, TextPosition l,
const ParagraphFormat& fmt, View& v)
: TextFlow(p, f, l) { view_ = &v; fmt_ = fmt; };
void line_shape(TextPosition, Extent&) const;
const View& view() const
{ return *view_; };
protected:
View* view_;
ParagraphFormat fmt_;
};
class TabFlow : public TextFlow{
public:
TabFlow(TextFlow& p, TextPosition f, TextPosition l,
ParagraphFormat& pf, View& v)
: TextFlow(p, f, l) { view_ = &v; fmt_ = pf; };
Qty character_shape(TextPosition, Qty, Extent, Extent&, int) const;
Coord next_tab_stop(Coord here) const;
const View& view() const
{ return *view_; };
protected:
View* view_;
ParagraphFormat fmt_;
};
#endif